package com.lh.runmanage.service.Impl;

import com.lh.runmanage.dao.ColMapper;
import com.lh.runmanage.model.ColModel;
import com.lh.runmanage.model.InPutParam.ColInParam;
import com.lh.runmanage.service.ColService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author ：梁昊，后端工程师：梁昊
 * @create 2021-07-12 18:15
 * @function
 * @editLog
 */
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Service
public class ColServiceImpl implements ColService {
    @Autowired
    ColMapper colMapper;

    @Override
    public List<ColModel> selectColByProjectCode(ColInParam colInParam) {
        return colMapper.selectColByProjectCode(colInParam);
    }

    /**
     * 得到单位菜单值
     *
     * @param colInParam 菜单功能ID
     * @return 一个菜单值
     */
    @Override
    public ColModel selectColById(ColInParam colInParam) {
        return colMapper.selectColById(colInParam);
    }

    /**
     * 增加一个菜单值
     *
     * @param colInParam com.lh.runmanage.model.InPutParam.ColInParam
     * @return 影响条数
     */
    @Override
    public int insertCol(ColInParam colInParam) {
        return colMapper.insertCol(colInParam);
    }

    /**
     * 修改一个菜单值
     *
     * @param colInParam com.lh.runmanage.model.InPutParam.ColInParam
     * @return 影响条数
     */
    @Override
    public int updateColById(ColInParam colInParam) {
        return colMapper.updateColById(colInParam);
    }

    /**
     * 删除一个菜单值
     *
     * @param colInParam com.lh.runmanage.model.InPutParam.ColInParam
     * @return 影响条数
     */
    @Override
    public int deleteColById(ColInParam colInParam) {
        return colMapper.deleteColById(colInParam);
    }

    /**
     * 得到指定项目菜单权重
     *
     * @param projectCode 项目ID
     * @return 菜单权重
     */
    @Override
    public BigDecimal selectColTotalWeightByProjectId(String projectCode) {
        final BigDecimal bigDecimal = colMapper.selectColTotalWeightByProjectId(projectCode);
        return bigDecimal != null ? bigDecimal : BigDecimal.valueOf(0);
    }

}